import 'package:dk_flutter_base/dk_core.dart';
class CommonSearchBean {
  String placeholder;
  String type;
  List<CommonSearchItemBean> listData;

  CommonSearchBean({this.placeholder, this.type, this.listData});

  CommonSearchBean.fromJson(Map<String, dynamic> json) {
    this.placeholder = json['placeholder'];
    this.type = json['type'];
    this.listData = (json['listData'] as List) != null
        ? (json['listData'] as List)
            .map((i) => CommonSearchItemBean.fromJson(i))
            .toList()
        : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['placeholder'] = this.placeholder;
    data['type'] = this.type;
    data['listData'] = this.listData != null
        ? this.listData.map((i) => i.toJson()).toList()
        : null;
    return data;
  }
}

class CommonSearchItemBean {
  String title;
  String jumpType;
  String searchKey;

  CommonSearchItemBean({this.title, this.jumpType, this.searchKey});

  CommonSearchItemBean.fromJson(Map<String, dynamic> json) {
    this.title = json['title'];
    this.jumpType = json['jumpType'];
    this.searchKey = json['searchKey'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['title'] = this.title;
    data['jumpType'] = this.jumpType;
    data['searchKey'] = this.searchKey;
    return data;
  }
}

class SearchHistoryListBean {
  List<SecondSearchItem> historyList;

  SearchHistoryListBean({this.historyList});

  SearchHistoryListBean.fromJson(Map<String, dynamic> json) {
    this.historyList = (json['historyList'] as List) != null
        ? (json['historyList'] as List)
            .map((i) => SecondSearchItem.fromJson(i))
            .toList()
        : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['historyList'] = this.historyList != null
        ? this.historyList.map((i) => i.toJson()).toList()
        : null;
    return data;
  }
}

class SecondSearchItem {
  String searchKey;
  String searchValue;
  String displayName;

  SecondSearchItem({this.searchKey, this.searchValue, this.displayName});

  SecondSearchItem.fromJson(Map<String, dynamic> json) {
    this.searchKey = json['searchKey'];
    this.searchValue = json['searchValue'];
    this.displayName = json['displayName'];
  }

  Map<String, String> toJson() {
    final Map<String, String> data = new Map<String, String>();
    data['searchKey'] = this.searchKey;
    data['searchValue'] = this.searchValue;
    data['displayName'] = this.displayName;
    return data;
  }

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is SecondSearchItem &&
          runtimeType == other.runtimeType &&
          searchKey == other.searchKey &&
          searchValue == other.searchValue &&
          displayName == other.displayName;

  @override
  int get hashCode =>
      searchKey.hashCode ^ searchValue.hashCode ^ displayName.hashCode;
}

class SaleNameListRequest {
  String keyWord;
  String useTo;

  SaleNameListRequest({this.keyWord,this.useTo});

  SaleNameListRequest.fromJson(Map<String, dynamic> json) {
    this.keyWord = json['key_word'];
    this.useTo = json['useTo'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['key_word'] = this.keyWord;
    if(stringNotEmpty(this.useTo)){
      data['useTo'] = this.useTo;
    }
    return data;
  }
}

class SaleNameList {
  List<SaleNameItem> list;

  SaleNameList({this.list});

  factory SaleNameList.fromJson(List<dynamic> listJson) {
    List<SaleNameItem> list =
        listJson.map((value) => SaleNameItem.fromJson(value)).toList();
    return SaleNameList(list: list);
  }
}

class SaleNameItem {
  num id;
  String name;
  String onlyName;

  SaleNameItem({this.id, this.name, this.onlyName});

  SaleNameItem.fromJson(Map<String, dynamic> json) {
    this.id = json['id'];
    this.name = json['name'];
    this.onlyName = json['only_name'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['name'] = this.name;
    data['only_name'] = this.onlyName;
    return data;
  }
}
